home *** CD-ROM | disk | FTP | other *** search
/ Hráč 2004 August / Hrac_72_2004-08_dvd.iso / dema / Rapid Gun / rg_setup.exe / common / image_GaussianBlur.fx < prev    next >
Text File  |  2004-04-19  |  2KB  |  59 lines

  1. // LF2 Engine
  2. // (C) 2002-3 7FX
  3. //---------------------------------------------------------------------------
  4. // Desc
  5. string desc : Description = "Image shader - 3x3 gaussian blur.";
  6. // Shader type phase
  7. string type : Type = "image";
  8. //---------------------------------------------------------------------------
  9. // Constants
  10. const float4 cLum = {0.3f, 0.59f, 0.11f, 1.f};
  11. const float2 sampleOffsets[8] : SampleOffsets;
  12. // Render target texture
  13. texture RT : RenderTargetFSMap;
  14. //---------------------------------------------------------------------------
  15. sampler sRT = sampler_state
  16. {
  17.     Texture = <RT>;
  18.     MinFilter = POINT;
  19.     MagFilter = POINT;
  20.     AddressU = CLAMP;
  21.     AddressV = CLAMP;
  22. };
  23. //---------------------------------------------------------------------------
  24. // Pixel shader
  25. float4 PS(float2 uv: TEXCOORD0) : COLOR
  26. {
  27.     int i =0;
  28.     float4 c = .5;
  29.     float2 texCoords;
  30.     float4 texSamples[8];
  31.     float4 total=0;
  32.     float  multipliers[8]= {1,2,1,
  33.                             2,  2,
  34.                             1,2,1};
  35.  
  36.     for(i =0; i<8; i++)
  37.     {
  38.         texCoords = uv + sampleOffsets[i];    // add sample offsets
  39.         // take sample, mul by by kernel
  40.         total += tex2D(sRT, texCoords) * multipliers[i]; 
  41.     }
  42.  
  43.     total += 4 * tex2D(sRT, uv);
  44.     c = total/16.0;
  45.  
  46.     return c;
  47. }
  48. //---------------------------------------------------------------------------
  49. technique vs0_ps20
  50. {
  51.     pass p0
  52.     {
  53.            ZEnable = false;
  54.         ZWriteEnable = false;
  55.    
  56.         PixelShader  = compile ps_2_0 PS();
  57.     }
  58. }
  59. //---------------------------------------------------------------------------